package com.sky.controller.admin;

import com.google.common.collect.Lists;
import com.sky.dto.TurnoverReportDTO;
import com.sky.result.Result;
import com.sky.service.ReporService;
import com.sky.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/admin/report")
@Api(value = "数据统计相关接口")
public class ReportController {
    @Autowired
    private ReporService reporService;


    @GetMapping("/turnoverStatistics")
    @ApiOperation(value = "营业额统计")
    private Result<TurnoverReportVO> turnoverStatistics(TurnoverReportDTO turnoverReportDTO){
        return Result.success(reporService.turnoverStatistics(turnoverReportDTO));
    }

    @GetMapping("/ordersStatistics")
    @ApiOperation(value = "订单统计")
    private Result<OrderReportVO> ordersStatistics(TurnoverReportDTO turnoverReportDTO) {
        return Result.success(reporService.ordersStatistics(turnoverReportDTO));
    }


    @GetMapping("/top10")
    @ApiOperation(value = "热销菜品top10")
    private Result top(TurnoverReportDTO turnoverReportDTO) {
        return Result.success(reporService.top(turnoverReportDTO));
    }

    @GetMapping("/userStatistics")
    @ApiOperation(value = "用户统计")
    private Result<UserReportVO> userStatistics(TurnoverReportDTO turnoverReportDTO) {
        return Result.success(reporService.userStatistics(turnoverReportDTO));
    }


    @GetMapping("/export")
    @ApiOperation(value = "导出")
    private void export(HttpServletResponse response) throws IOException {
        reporService.export(response);
    }

}
